Add chunked upload documentation for rx.upload_files_chunk#6259
Add chunked upload documentation for rx.upload_files_chunk#6259masenf merged 4 commits intoreflex-dev:mainfrom
Conversation
Document the new rx.upload_files_chunk API for incremental large file uploads, including handler requirements, chunk properties, and a complete code example. Update the progress section and API routes overview to cover both upload methods.
Greptile SummaryThis PR documents the new Key changes:
Issues found:
Confidence Score: 4/5Not safe to merge as-is: the broken reflex-web submodule must be removed before merging. One P1 finding (broken orphan submodule with no .gitmodules) must be fixed before merging. The P2 finding (stale bytes in example code) is a documentation-quality issue that should ideally also be addressed. Once both are resolved the PR is ready. The reflex-web submodule entry at the repo root must be removed with Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant UploadJS as upload.js (XHR)
participant UploadRoute as /_upload route
participant ChunkParser as _UploadChunkMultipartParser
participant ChunkIter as UploadChunkIterator
participant Handler as handle_large_upload (background)
Browser->>UploadJS: on_click → rx.upload_files_chunk(upload_id)
UploadJS->>UploadRoute: POST multipart/form-data (streaming)
UploadRoute->>ChunkIter: create UploadChunkIterator
UploadRoute->>Handler: dispatch @rx.event(background=True) with chunk_iter
UploadRoute->>ChunkParser: parse(stream, chunk_iter)
loop for each network packet
ChunkParser->>ChunkIter: push(UploadChunk{filename, offset, content_type, data})
ChunkIter-->>Handler: yield chunk
Handler->>Handler: seek(chunk.offset) + write(chunk.data)
end
ChunkParser->>ChunkIter: finish()
Handler->>Handler: close file handles
Handler->>Handler: async with self → update state
UploadJS-->>Browser: on_upload_progress({loaded, total, progress})
Reviews (1): Last reviewed commit: "Add chunked upload documentation for rx...." | Re-trigger Greptile |
reflex/docs/library/forms/upload.md
Outdated
| Your event handler should be an async function that accepts a single argument, | ||
| `files: list[UploadFile]`, which will contain [FastAPI UploadFile](https://fastapi.tiangolo.com/tutorial/request-files) instances. | ||
| You can read the files and save them anywhere as shown in the example. | ||
| For uploads, your event handler should be an async function that accepts a single argument, `files: list[UploadFile]`, which will contain [FastAPI UploadFile](https://fastapi.tiangolo.com/tutorial/request-files) instances. You can read the files and save them anywhere as shown in the example. |
There was a problem hiding this comment.
while we're in here, lets change this to Starlette's UploadFile, since that's closer to what we're using.
but probably should include the generated docs for our UploadFile class eventually, since that is what we actually use
reflex/docs/library/forms/upload.md
Outdated
| Use `rx.upload_files_chunk(...)` when files may be large or when you want the | ||
| backend to write data incrementally instead of waiting for the full upload | ||
| before the handler starts. |
There was a problem hiding this comment.
i know you say "large" here, but i would explicitly mention something about memory consumption being higher when buffering files
…f the tranditional uploads.
Document the new rx.upload_files_chunk API for incremental large file uploads, including handler requirements, chunk properties, and a complete code example. Update the progress section and API routes overview to cover both upload methods.
All Submissions:
Type of change
New Feature Submission:
closes #6207